package tag.system;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.tagext.Tag;
import javax.servlet.jsp.tagext.TagSupport;

import org.eu.config.Config;
import org.eu.config.ConfigManager;

public class ShowInfo extends TagSupport {

	String name=null;
	/**
	 * 
	 */
	Config config=ConfigManager.getGlobalConfig("System.Config");
	
	private static final long serialVersionUID = -3099027948506931075L;

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.servlet.jsp.tagext.TagSupport#doEndTag()
	 */
	@Override
	public int doEndTag() throws JspException {
		// TODO Auto-generated method stub
		return super.doEndTag();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.servlet.jsp.tagext.TagSupport#doStartTag()
	 */
	@Override
	public int doStartTag() throws JspException {
		// TODO Auto-generated method stub
		try {
			if(config==null)
				return Tag.EVAL_BODY_INCLUDE;
			String value=config.getValueNE(name);
			if(name.equals("powerby"))
				value="FileSharer";
			else if(name.equals("powerby_site"))
				value="http://projects.wzzcn.net/filesharer/";
			else if(name.equals("version"))
				value="1.0 Alpha";
			if(value==null)
				value="";
			pageContext.getOut().write(value);// 标签的返回值
		} catch (IOException ex) {
			throw new JspTagException("错误");
		}
		return super.doStartTag();
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	
}
